package com.linkallcloud.core.dto;

import com.linkallcloud.core.util.ImageUtils;
import com.linkallcloud.core.vo.Vo;

public class ArchiveVo extends Vo {
    private static final long serialVersionUID = -7571835305791912778L;

    private String objectId;
    private String realName;
    private String path;
    private Integer fileType;

    public ArchiveVo() {
        super();
    }

    public ArchiveVo(Object o) {
        super(o);
    }

    public static ArchiveVo from(Archive archive) {
        ArchiveVo vo = new ArchiveVo();
        vo.setObjectId(archive.getObjectId());
        vo.setRealName(archive.getRealName());
        vo.setPath(archive.getPath());
        vo.setFileType(archive.getFileType());
        return vo;
    }

    public String getObjectId() {
        return objectId;
    }

    public void setObjectId(String objectId) {
        this.objectId = objectId;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public Integer getFileType() {
        return fileType;
    }

    public void setFileType(Integer fileType) {
        this.fileType = fileType;
    }

    public String getIcon() {
        String fileExtName = ImageUtils.parseFileExtName(this.getRealName());
        if ("doc".equals(fileExtName) || "docx".equals(fileExtName)) {
            return "fa-file-word-o";
        } else if ("xls".equals(fileExtName) || "xlsx".equals(fileExtName)) {
            return "fa-file-excel-o";
        } else if ("ppt".equals(fileExtName) || "pptx".equals(fileExtName)) {
            return "fa-file-powerpoint-o";
        } else if ("pdf".equals(fileExtName)) {
            return "fa-file-pdf-o";
        } else if ("txt".equals(fileExtName)) {
            return "fa-file-text-o";
        } else if ("zip".equals(fileExtName) || "rar".equals(fileExtName)) {
            return "fa-file-zip-o";
        }
        return "fa-file-text-o";
    }

}
